home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 58271 / 58271.xpi / chrome / content / schedWin.js < prev    next >
Encoding:
Text File  |  2010-02-07  |  2.0 KB  |  58 lines

  1. if(!tim_matthews) var tim_matthews={};
  2. if(!tim_matthews.downloadScheduler) tim_matthews.downloadScheduler={};
  3. if(!tim_matthews.downloadScheduler.schedWin_js) tim_matthews.downloadScheduler.schedWin_js = {};
  4.  
  5. tim_matthews.downloadScheduler.schedWin_js = {
  6.  
  7.   list1: {},
  8.  
  9.   init: function() {
  10.       try {
  11.           tim_matthews.downloadScheduler.schedWin_js.list1 = document.getElementById("tim_matthews.downloadScheduler.schedWin.list1");
  12.           tim_matthews.downloadScheduler.schedWin_js.refreshList();
  13.       } catch (e) {
  14.           alert(e);
  15.       }
  16.   },
  17.  
  18.   refreshList: function() {
  19.       try {
  20.           while(tim_matthews.downloadScheduler.schedWin_js.list1.itemCount > 0)
  21.               tim_matthews.downloadScheduler.schedWin_js.list1.removeItemAt(0);
  22.  
  23.           var downloadArray = Application.storage.get("tim_matthews.downloadScheduler.downloadArray",  null);
  24.           for (var i=0; i<downloadArray.length; i++) {
  25.               var scheduleSlot = downloadArray[i];
  26.               if((scheduleSlot == undefined) || (scheduleSlot==null))
  27.                   continue;
  28.  
  29.               var s = scheduleSlot.sourceURI.scheme + "://" + scheduleSlot.sourceURI.host + scheduleSlot.sourceURI.path;
  30.               var listitem = tim_matthews.downloadScheduler.schedWin_js.list1.appendItem(s, scheduleSlot).setAttribute("tooltiptext", s);
  31.           }
  32.       } catch (e) {
  33.           alert(e);
  34.       }
  35.   },
  36.  
  37.   cancelDownload: function() {
  38.       try {
  39.           var index = tim_matthews.downloadScheduler.schedWin_js.list1.selectedIndex;
  40.           if(index == -1)
  41.               return;
  42.           
  43.           var downloadArray = Application.storage.get("tim_matthews.downloadScheduler.downloadArray",  null);
  44.  
  45.           var scheduleSlot = downloadArray[index];
  46.           if(scheduleSlot.newFile)
  47.               scheduleSlot.targetFile.remove(false);
  48.  
  49.           downloadArray.splice(index, 1);
  50.           tim_matthews.downloadScheduler.schedWin_js.refreshList();
  51.       } catch (e) {
  52.           alert(e);
  53.       }
  54.   }
  55.  
  56. };
  57.  
  58.